package com.zmj.sy.mom.srv.aps.utils;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import org.springframework.stereotype.Component;

@Component
public class JsonUtils {

    private static ObjectMapper objectMapper;
    public JsonUtils(ObjectMapper o) {
        objectMapper = o;
    }

    @SneakyThrows
    public static String toJsonString(Object o) {
        return objectMapper.writeValueAsString(o);
    }

    @SneakyThrows
    public static JsonNode readTree(String jsonString) {
        return objectMapper.readTree(jsonString);
    }


}
